package com.dingreading.cloud.admin.service;

import com.dingreading.cloud.admin.dto.RealUsableNumDto;
import com.dingreading.cloud.admin.entity.WhStockIn;
import com.dingreading.cloud.common.util.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 服务层。
 *
 * @author Administrator
 * @since 2023-11-22
 */
public interface WhStockInService extends IService<WhStockIn> {

    Page<WhStockIn> pageList(PageUtil pageUtil, String keyword, Integer status, String beginDate, String endDate);

    Page<WhStockIn> returnList(PageUtil pageUtil, String keyword, Integer status);

    int dropData(String inCode);

    List<WhStockIn> getByPurchaseId(Long purchaseGoodsId);

    long getByPurchaseIdCnt(Long purchaseGoodsId);

    WhStockIn getByInCode(String inCode);

    List<WhStockIn> getByInCodes(List<String> inCodes);

    // 获取采购的入库记录数量
    long getPurchaseCodeCnt(String purchaseCode, Integer status);

    // 获取商品规格的剩余库存数量
    int getGoodsTypeUsableNum(Long goodsTypeId);

    // 获取符合出库数量的入库记录
    List<WhStockIn> getOkGoodsTypeUsableNumLog(Long goodsTypeId, Integer buyNum);

    int updateUsableNum(Map<Long, Integer> map, String time);

    List<WhStockIn> getByPurchaseCode(String purchaseCode);

    // 获取已入库的总数
    int getRealNumCnt(Long purchaseGoodsId);

    // 完成入库
    boolean setOk(String inCode, Long operatorId, String operator, Integer usableNum, double inAmount, Date time);

    boolean setOk(String inCode, String operatorUid, String operator, Integer usableNum, double inAmount, Date time);

    // 退回入库单的库存数
    boolean setReturn(String inCode, String operatorUid, String operator, String remark, int returnNum, double returnPrice, Date time);

    // 汇总采购订单号的实际入库数、剩余总库存数
    Map<String, RealUsableNumDto> getRealNumAndUsableNumByPurchaseCode(List<String> purchaseCode);

    // 获取多个商品规格的剩余库存数量
    Map<Long, Integer> getStockNumMap(List<Long> goodsTypeIds);

    // 获取商品的入库总数量
    Map<Long, Integer> getInNum(List<Long> goodsTypeIds);

    // 按日期获取商品的入库总数量
    Map<Long, List<WhStockIn>> listByGoodsTypeIdAndAddTimeBetween(List<Long> goodsTypeIds, String beginDate, String endDate);

    List<WhStockIn> exportList(String keyword, String beginDate, String endDate);

}
